package com.zyz.friend.controller.userquestion;

import com.zyz.api.model.vo.UserQuestionResultVO;
import com.zyz.common.core.model.Result;
import com.zyz.friend.aspect.CheckUserStatus;
import com.zyz.friend.model.userquestion.dto.UserSubmitDTO;
import com.zyz.friend.service.userquestion.IUserQuestionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/user/question")
public class UserQuestionController {

    @Autowired
    private IUserQuestionService userQuestionService;

    @CheckUserStatus
    @RequestMapping(value = "/submit",method = RequestMethod.POST)
    public Result<UserQuestionResultVO> submit (@RequestBody UserSubmitDTO userSubmitDTO) {
        return userQuestionService.submit(userSubmitDTO);
    }

    @CheckUserStatus
    @RequestMapping(value = "/rabbit/submit",method = RequestMethod.POST)
    public Result<Void> rabbitSubmit (@RequestBody UserSubmitDTO userSubmitDTO) {
        return userQuestionService.rabbitSubmit(userSubmitDTO)? Result.ok() :Result.fail();
    }

    @RequestMapping(value = "/exe/result",method = RequestMethod.GET)
    public Result<UserQuestionResultVO> exeResult (Long examId, Long questionId, String currentTime) {
        return Result.ok(userQuestionService.exeResult(examId,questionId, currentTime));
    }

}
